package com.geekaca;

import com.geekaca.dao.BookDao;
import com.geekaca.service.BookService;
import com.geekaca.service.BrandService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Arrays;

public class TestMain {
    public static void main(String[] args) {
        testConstructor();
        testProterties();

    }

    public static void testConstructor() {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        BrandService brandService = (BrandService) ctx.getBean("brandService");
        brandService.save();

    }

    public static void test() {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
                "applicationContext.xml");
//        Teacher myTeacher = (Teacher) ctx.getBean("myTeacher");
//        myTeacher.sayHello();
        BookService bookservice = (BookService) ctx.getBean("bookService");
        bookservice.save();
    }

    public static void testProterties() {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        BookDao bookD = (BookDao) ctx.getBean("bookD");
        System.out.println(Arrays.toString(bookD.getMyArray()));
    }
}
